package com.huawei.hwid.usecase;

import android.content.Context;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable.Creator;
import android.text.TextUtils;
import com.huawei.cloudservice.CloudRequestHandler;
import com.huawei.hwid.UseCase;
import com.huawei.hwid.core.b.a.a.d;
import com.huawei.hwid.core.d.b.e;
import com.huawei.hwid.core.helper.handler.ErrorStatus;

public class QueryTrustCircleStatusUseCase extends UseCase<RequestValues> {
    private Context a;
    private CloudRequestHandler b;

    public static final class RequestValues extends com.huawei.hwid.UseCase.RequestValues {
        public static final Creator<RequestValues> CREATOR = new Creator<RequestValues>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return a(parcel);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return a(i);
            }

            public RequestValues a(Parcel parcel) {
                return new RequestValues(parcel);
            }

            public RequestValues[] a(int i) {
                return new RequestValues[i];
            }
        };
        private String a;
        private String b;
        private String c;
        private String d;
        private int e;

        protected RequestValues(Parcel parcel) {
            this.a = parcel.readString();
            this.b = parcel.readString();
            this.c = parcel.readString();
            this.d = parcel.readString();
            this.e = parcel.readInt();
        }

        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeString(this.a);
            parcel.writeString(this.b);
            parcel.writeString(this.c);
            parcel.writeString(this.d);
            parcel.writeInt(this.e);
        }
    }

    class a implements CloudRequestHandler {
        final /* synthetic */ QueryTrustCircleStatusUseCase a;

        private a(QueryTrustCircleStatusUseCase queryTrustCircleStatusUseCase) {
            this.a = queryTrustCircleStatusUseCase;
        }

        public void onFinish(Bundle bundle) {
            e.b("QueryTrustCircleStatusUseCase", "QueryTrustCircleRequestHandler onFinish ", true);
            if (TextUtils.isEmpty(bundle.getString("tcisAT"))) {
                this.a.b.onError(new ErrorStatus(48, "trust circle is not verified"));
            } else {
                this.a.b.onFinish(bundle);
            }
        }

        public void onError(ErrorStatus errorStatus) {
            e.b("QueryTrustCircleStatusUseCase", "QueryTrustCircleRequestHandler error ", true);
            this.a.b.onError(new ErrorStatus(48, "trust circle is not verified"));
        }
    }

    public /* synthetic */ void b(com.huawei.hwid.UseCase.RequestValues requestValues) {
        a((RequestValues) requestValues);
    }

    protected void a(RequestValues requestValues) {
        e.b("QueryTrustCircleStatusUseCase", "QueryTrustCircleStatusUseCase", true);
        b(requestValues);
    }

    private void b(RequestValues requestValues) {
        com.huawei.hwid.core.b.a.a dVar = new d(this.a, requestValues.a, requestValues.b, requestValues.c, requestValues.d, requestValues.e);
        dVar.a(this.a, dVar, null, new a());
    }
}
